<?php

namespace App\Http\Requests\Api;


class ImageRequest extends FormRequest
{
   public function rules()
    {
        $rules = [
            'type'=>['required','string','in:avatar,topic']
        ];
        if($this->type == 'avatar'){
            $rules['image'] = ['required','mimes:jgp,png,gif,jpeg','dimensions:min_width=300,min_height=300'];
        }else{
            $rules['image'] = ['required','mimes:jgp,png,gif,jpeg'];
        }
        return $rules;
    }
    public function messages() {
        return [
            'image.dimensions'=>'头像图片宽高都不能小于300像素'
        ];
    }
}
